package com.gzhryc.net_marketing.cloud.goods.dao.db;

import java.util.Date;

import org.apache.commons.lang3.StringUtils;

import com.gzhryc.common.NumberTools;
import com.gzhryc.common.StringTools;
import com.gzhryc.jdbc.annotaion.Column;
import com.gzhryc.jdbc.annotaion.Id;
import com.gzhryc.jdbc.annotaion.Index;
import com.gzhryc.jdbc.annotaion.JoinField;
import com.gzhryc.jdbc.annotaion.Table;
import com.gzhryc.net_marketing.cloud.goods.dao.enums.GoodsEnum;
import com.gzhryc.net_marketing.core.enums.EGoodsClassify;
import com.gzhryc.shared_device.common.payment.dao.enums.EAppType;

@Table(name = "goods_info")
public class Goods {

	@Id(autoIncrement = 770000)
	@Column
	protected Long id;
	
	@Index(name="project")
	@Column(name = "project_id",notNull = true,note = "项目ID")
	protected Long projectId;
	
	@Column(name = "app_type",notNull = true,note = "App类型")
	protected Integer appType;
	
	@Index(name="app")
	@Column(name = "app_id",notNull = true,note = "AppId")
	protected String appId;

	@Column(notNull = true,length = 64,note = "商品名称")
	protected String name;

	@Column(name="classify",notNull = true,defVal = "1",note = "商品类型，1：实物，2：虚拟")
	protected Integer classify;

	@Column(name="type_codes",length = 255)
	protected String typeCodes;

	@Column(name="type_names",length = 255)
	protected String typeNames;

	@Column(name="thumbnail_img",length = 128,note="缩略图")
	protected String thumbnailImg;

	@Column(length = 2048)
	protected String imgs;

	@Column(name="detail_imgs",length = 2048,note="详情图")
	protected String detailImgs;

	@Column(length = 64, note = "标签集")
	protected String labels;
	
	@Column(name = "source_type",notNull = true,defVal = "1",note = "来源类型，1:自有，2:供货商")
	protected Integer sourceType;

	@Column
	protected String code;

	@Column(name = "supplier_id",note="供应商ID")
	protected Long supplierId;

	@Column(name = "supplier_name",note="供应商名称")
	protected String supplierName;

	@Column(name = "pay_money",notNull = true,defVal = "0",note = "零售价格")
	protected Integer payMoney;

	@Column(name = "wholesale_money",notNull = true,defVal = "0",note = "批发价格")
	protected Integer wholesaleMoney;
	
	@Column(name = "team_pay_money",notNull = true,defVal = "0", note = "团拼金额")
	protected Integer teamPayMoney;

	@Column(name = "team_count",notNull = true,defVal = "0", note = "团拼数量")
	protected Integer teamCount;

	@Column(name = "gain_count",notNull = true,defVal = "0", note = "商品购买数，0：不限制，其他数值限制")
	protected Integer gainCount;

	@Column(name = "team_minute",notNull = true,defVal = "30", note = "团拼时间，单位：分钟")
	protected Integer teamMinute;

	@Column(name = "can_virtual_money",notNull = true,defVal = "false", note = "是否可以使用积分")
	protected Boolean canVirtualMoney;
	
	@Column(notNull = true,defVal = "1",note = "状态")
	protected Integer state;

	@Column(name = "update_date", autoUpdateTime = true)
	protected Date updateDate;

	@Column(name = "create_date")
	protected Date createDate;
	
	@JoinField(name="name",fromField="project_id",toTable="market_project_app")
	protected String projectName;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getProjectId() {
		return projectId;
	}

	public void setProjectId(Long projectId) {
		this.projectId = projectId;
	}

	public Integer getAppType() {
		return appType;
	}

	public void setAppType(Integer appType) {
		this.appType = appType;
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public Integer getClassify() {
		return classify;
	}

	public void setClassify(Integer classify) {
		this.classify = classify;
	}

	public String getTypeCodes() {
		return typeCodes;
	}

	public void setTypeCodes(String typeCodes) {
		this.typeCodes = typeCodes;
	}

	public String getTypeNames() {
		return typeNames;
	}

	public void setTypeNames(String typeNames) {
		this.typeNames = typeNames;
	}
	
	public Integer getSourceType() {
		return sourceType;
	}

	public void setSourceType(Integer sourceType) {
		this.sourceType = sourceType;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Long getSupplierId() {
		return supplierId;
	}

	public void setSupplierId(Long supplierId) {
		this.supplierId = supplierId;
	}

	public String getSupplierName() {
		return supplierName;
	}

	public void setSupplierName(String supplierName) {
		this.supplierName = supplierName;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getThumbnailImg() {
		return thumbnailImg;
	}

	public void setThumbnailImg(String thumbnailImg) {
		this.thumbnailImg = thumbnailImg;
	}

	public String getImgs() {
		return imgs;
	}

	public void setImgs(String imgs) {
		this.imgs = imgs;
	}

	public String getDetailImgs() {
		return detailImgs;
	}

	public void setDetailImgs(String detailImgs) {
		this.detailImgs = detailImgs;
	}

	public Integer getPayMoney() {
		return payMoney;
	}

	public void setPayMoney(Integer payMoney) {
		this.payMoney = payMoney;
	}

	public String getLabels() {
		return labels;
	}

	public void setLabels(String labels) {
		this.labels = labels;
	}

	public Integer getWholesaleMoney() {
		return wholesaleMoney;
	}

	public void setWholesaleMoney(Integer wholesaleMoney) {
		this.wholesaleMoney = wholesaleMoney;
	}

	public Integer getTeamPayMoney() {
		return teamPayMoney;
	}

	public void setTeamPayMoney(Integer teamPayMoney) {
		this.teamPayMoney = teamPayMoney;
	}
	
	public Integer getTeamCount() {
		return teamCount;
	}

	public void setTeamCount(Integer teamCount) {
		this.teamCount = teamCount;
	}

	public Integer getGainCount() {
		return gainCount;
	}

	public void setGainCount(Integer gainCount) {
		this.gainCount = gainCount;
	}

	public Integer getTeamMinute() {
		return teamMinute;
	}

	public void setTeamMinute(Integer teamMinute) {
		this.teamMinute = teamMinute;
	}

	public Boolean getCanVirtualMoney() {
		return canVirtualMoney;
	}

	public void setCanVirtualMoney(Boolean canVirtualMoney) {
		this.canVirtualMoney = canVirtualMoney;
	}

	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public String getPayMoneyStr() {
		return NumberTools.getMoneyStr(this.payMoney);
	}

	public String getTeamPayMoneyStr() {
		return NumberTools.getMoneyStr(this.teamPayMoney);
	}

	public String getWholesaleMoneyStr(){
		return NumberTools.getMoneyStr(wholesaleMoney);
	}
	
	public String getStateName() {
		return GoodsEnum.State.note(this.state);
	}

	public String getClassifyName(){
		return EGoodsClassify.note(this.classify);
	}
	
	public String getAppTypeName(){
		return EAppType.note(this.appType);
	}
	
	public String getSourceTypeName() {
		return GoodsEnum.SourceType.note(this.sourceType);
	}

	public String[] getImgPaths(){
		if(StringUtils.isNotBlank(this.getImgs())){
			String[] imgPaths = this.getImgs().split("\\|");
			return imgPaths;
		}
		return null;
	}

	public String[] getDetailImgPaths(){
		if(StringUtils.isNotBlank(this.getDetailImgs())){
			String[] imgPaths = this.getDetailImgs().split("\\|");
			return imgPaths;
		}
		return null;
	}

	public Boolean getIsCloudGoods(){
		return StringTools.isNotBlank(this.code);
	}
}
